﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace brand.cyt369.com.models.WebRequest
{
    public class HttpResponse {
        private Encoding m_Encoding;

        public System.Net.HttpStatusCode StatusCode { get; set; }

        public System.IO.MemoryStream Stream { get; set; }

        public HttpCookie Cookies { get; set; }

        public HttpResponseHeaderList Headers { get; set; }

        public Encoding Encoding {
            get { return m_Encoding; }
        }

        public string ContentString {
            get {
                if (this.Stream != null) {
                    return m_Encoding.GetString(this.Stream.ToArray());
                } else {
                    return null;
                }
            }
        }

        public HttpResponse() { }
        public HttpResponse(Encoding encoding) {
            if (encoding == null) {
                this.m_Encoding = System.Text.Encoding.UTF8;
            } else {
                this.m_Encoding = encoding;
            }
        }

        public override string ToString() {
            return this.ContentString;
        }
    }
}
